﻿#region 命名空间

using System;
using System.Linq;
using Microsoft.Practices.ObjectBuilder2;
using Sharp.Application;
using Sharp.Infrastructure.Crosscutting;
using Sharp.Infrastructure.Interfaces;
using Sharp.Infrastructure.IoC;
using Sharp.Services.Models;

#endregion

namespace Sharp.Services
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            IoCContainer.ConfigureContainer();
            var bootstraps = ServiceLocator.Instance.GetServiceAll<IBootstrapPlugin>().ToArray();
            bootstraps.ForEach(x =>
            {
                if (!x.IsAlready)
                    x.Initialize();
            });
            
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            //LogHelper.Critical(System.Web.HttpContext.Current.Request.Url);
            LogHelper.Critical("Application_BeginRequest " + DateTime.Now);
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
        }

        protected void Application_Error(object sender, EventArgs e)
        {
        }

        protected void Session_End(object sender, EventArgs e)
        {
        }

        protected void Application_End(object sender, EventArgs e)
        {
        }
    }
}